home *** CD-ROM | disk | FTP | other *** search
/ CD-ROM Data 2002 May / CD Rom Data Mayıs 2002.iso / Freeware / Blitz Basic / data1.cab / Support / help / samples / maze / mazetest.bb < prev   
Encoding:
Text File  |  2002-04-10  |  1.7 KB  |  101 lines

  1. ; (c) Graham Kennedy
  2.  
  3.  
  4. Include "mazelib.bb"
  5.  
  6. Graphics 800,600
  7.  
  8.     maze_startup("mazeblocks.png",16,16)
  9.  
  10.     mwidth = 32;     set a variable for the width 
  11.     mheight = 32;    and the height of the maze
  12.  
  13.  
  14.     SetBuffer BackBuffer()
  15. ;    Cls
  16. ;    m.maze = maze_create(mwidth,mheight,MilliSecs(),0)
  17. ;    maze_display(m,0)
  18. ;    Text 500,0,"Finished"
  19.  
  20.     
  21.     
  22.     finished = 0
  23.     x = 0
  24.     y = 0
  25. ;    maze_drawincell(x,y,255,255,255)
  26.     
  27. ;    Flip
  28.     
  29.     a$="n"
  30.     k = Asc(a$)
  31.     
  32.     While Not finished
  33.         Cls
  34.         
  35.         If a$ = "n" Then
  36.             If m.maze <> Null Then maze_Delete(m)
  37.             m.maze = maze_create(mwidth,mheight,MilliSecs(),0)
  38.             x = 0
  39.             y = 0        
  40.         End If
  41.         
  42.         If a$="r" And x <> mwidth-1 And y <> mheight-1 Then
  43.             maze_clearRoute(m)
  44.             maze_solve(m,x,y,mwidth-1,mheight-1)
  45.         End If
  46.         
  47.         If a$="s" Then maze_save(m,"maze.maz")
  48.         If a$="l" Then
  49.             maze_delete(m)
  50.             m = maze_load("maze.maz")
  51.         End If
  52.         
  53.         If a$ = "c" Then maze_clearroute(m)
  54.         
  55.         If k = 28 And maze_NorthOpen(m,x,y) Then
  56.             y=y-1
  57.         End If
  58.  
  59.         If k = 29 And maze_SouthOpen(m,x,y) Then
  60.             y=y+1
  61.         End If
  62.  
  63.         If k = 30 And maze_EastOpen(m,x,y) Then
  64.             x=x+1
  65.         End If
  66.  
  67.         If k = 31 And maze_WestOpen(m,x,y) Then
  68.             x=x-1
  69.         End If
  70.         
  71.         maze_display(m,1)
  72.         maze_drawincell(x,y,255,255,255)
  73.         Text 520,0, "Use arrow keys to move"
  74.         Text 520,12,"X = exit"
  75.         Text 520,24,"N = New maze"
  76.         Text 520,36,"R = Show me the route"
  77.         Text 520,48,"C = Clear the route"
  78.         Text 520,60,"S = Save Maze"
  79.         Text 520,72,"L = Load Maze"
  80.         Text 520,86,"<enter> = snapshot screen"
  81.  
  82.         Flip
  83.  
  84.         If k = 13 Then
  85.             SaveBuffer(FrontBuffer(),"maze.bmp") 
  86.         End If
  87.  
  88.         k = WaitKey()
  89.         a$ = Lower$(Chr$(k))
  90.         If a$ = "x" Then finished=1
  91.  
  92.     Wend
  93.         
  94.     
  95.     
  96.     maze_delete(m)
  97. ;Wend
  98.  
  99. maze_shutdown()
  100.  
  101. End